import { IsEnum, IsNotEmpty, IsString } from "class-validator";
import { BaseEntity } from "src/baseEntity";
import { System } from "src/system/system.entity";
import { Column, Entity, ManyToOne } from "typeorm";

export enum ContractType {
    劳务合同 = '劳务合同',
    保密协议 = '保密协议',
    安全协议 = '安全协议',
    商务合同 = '商务合同',
    项目合同 = '项目合同',
    服务合同 = '服务合同',
    代理合同 = '代理合同',
}
@Entity("contract")
export class Contract extends BaseEntity {
    @ManyToOne(() => System)
    system: System

    @Column({ type: "enum", enum: ContractType })
    @IsNotEmpty({ message: '类别不能为空' })
    @IsEnum(ContractType, { message: '无效的类别' })
    category: ContractType;

    @Column()
    @IsNotEmpty({ message: '签署方不能为空' })
    @IsString({ message: '签署方必须是字符串' })
    signer: string;

    @Column({
        type: "timestamp",
        nullable: true
    })
    @IsNotEmpty({ message: '签订时间不能为空' })
    signDate: Date;

    @Column({
        type: "timestamp",
        nullable: true
    })
    @IsNotEmpty({ message: '到期时间不能为空' })
    expiryDate: Date;

    // @Column()
    // @IsNotEmpty({ message: '签署时长不能为空' })
    // duration: string;
}